﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace QuizEngine.Data
{
    public class Question : DbTable
    {
        int _questionId;

        [DbType(SqlDbType.Int)]
        public int QuestionId
        {
            get { return _questionId; }
            set { _questionId = value; }
        }
        byte _questionType;

        public byte QuestionType
        {
            get { return _questionType; }
            set { _questionType = value; }
        }
        string _content;

        public string Content
        {
            get { return _content; }
            set { _content = value; }
        }
        int _quizId;

        public int QuizId
        {
            get { return _quizId; }
            set { _quizId = value; }
        }

        public Question()
        {
        }

        public Question(int questionId, byte questionType, string content, int quizId)
        {
            _questionId = questionId;
            _questionType = questionType;
            _content = content;
            _quizId = quizId;
        }

        List<Choice> _choices;
        public List<Choice> Choices
        {
            get 
            {
                getListChoice(_questionId);
                return _choices; 
            }
            private set { _choices = Choices; }
        }

        private void getListChoice(int questionId)
        {
            /*
            _choices = new List<Choice>();
            QuizEngineDataSet quizEngineDS = new QuizEngineDataSet();
            ChoiceTableAdapter choiceTblAdapter = new ChoiceTableAdapter();
            choiceTblAdapter.GetDataByQuestionId(_questionId);
            choiceTblAdapter.Fill(quizEngineDS.Choice);
            foreach (DataRow dataRow in quizEngineDS.Choice.Rows)
            {
                Choice choice = new Choice();
                choice.ChoiceId = Convert.ToInt32(dataRow["ChoiceId"]);
                choice.Content = dataRow["Content"].ToString();
                choice.Value = dataRow["Value"].ToString();
                choice.QuestionId = Convert.ToInt32(dataRow["QuestionId"]);
                _choices.Add(choice);
            }
             * */
        }

    }
}
